Alter proc sp_accounts_setup_info(


	@SO_ACCOUNTS_RECEIVABLE_ACCOUNT VARCHAR(50),
	@SO_DISTRIBUTOR_GENERAL_ACCOUNT VARCHAR(50),
	@CUSTOMER_GENERAL_ACCOUNT 	VARCHAR(50),		
	@SO_FILE_LOCATION 		VARCHAR(100),
	@SO_FILE_NAME 			VARCHAR(50),
	@PO_ACCOUNTS_PAYBLE_ACCOUNT 	VARCHAR(50),
	@PO_GENERAL_ACCOUNT 		VARCHAR(50),
	@PO_FILE_LOCATION 		VARCHAR(100),
	@PO_FILE_NAME 			VARCHAR(50),
	@PO_RECEIPT_FILE_LOCATION	VARCHAR(100),
	@PO_RECEIPT_FILE_NAME		VARCHAR(50)

	)

AS
BEGIN


	DECLARE @ROWCOUNT INT

	SELECT @ROWCOUNT = COUNT(*) FROM ACCOUNTS_SETUP_TABLE

	IF( @ROWCOUNT = 0)
	BEGIN

		INSERT INTO ACCOUNTS_SETUP_TABLE ( SO_ACCOUNTS_RECEIVABLE_ACCOUNT, SO_DISTRIBUTOR_GENERAL_ACCOUNT, CUSTOMER_GENERAL_ACCOUNT, SO_FILE_LOCATION, SO_FILE_NAME,
						PO_ACCOUNTS_PAYBLE_ACCOUNT, PO_GENERAL_ACCOUNT, PO_FILE_LOCATION, PO_FILE_NAME, TIME_STAMP, PO_RECEIPT_FILE_LOCATION, PO_RECEIPT_FILE_NAME )
			VALUES( @SO_ACCOUNTS_RECEIVABLE_ACCOUNT, @SO_DISTRIBUTOR_GENERAL_ACCOUNT, @CUSTOMER_GENERAL_ACCOUNT, @SO_FILE_LOCATION, @SO_FILE_NAME,
						@PO_ACCOUNTS_PAYBLE_ACCOUNT, @PO_GENERAL_ACCOUNT, @PO_FILE_LOCATION, @PO_FILE_NAME, CURRENT_TIMESTAMP, @PO_RECEIPT_FILE_LOCATION, @PO_RECEIPT_FILE_NAME)
	END
	ELSE
	BEGIN

		UPDATE ACCOUNTS_SETUP_TABLE SET SO_ACCOUNTS_RECEIVABLE_ACCOUNT	= @SO_ACCOUNTS_RECEIVABLE_ACCOUNT,
						SO_DISTRIBUTOR_GENERAL_ACCOUNT 	= @SO_DISTRIBUTOR_GENERAL_ACCOUNT,
						CUSTOMER_GENERAL_ACCOUNT 	= @CUSTOMER_GENERAL_ACCOUNT,
						SO_FILE_LOCATION 		= @SO_FILE_LOCATION,
						SO_FILE_NAME 			= @SO_FILE_NAME,
						PO_ACCOUNTS_PAYBLE_ACCOUNT 	= @PO_ACCOUNTS_PAYBLE_ACCOUNT,
						PO_GENERAL_ACCOUNT 		= @PO_GENERAL_ACCOUNT,
						PO_FILE_LOCATION 		= @PO_FILE_LOCATION,
						PO_FILE_NAME 			= @PO_FILE_NAME,
						TIME_STAMP			= CURRENT_TIMESTAMP,
						PO_RECEIPT_FILE_LOCATION	= @PO_RECEIPT_FILE_LOCATION,
						PO_RECEIPT_FILE_NAME		= @PO_RECEIPT_FILE_NAME

	END					

END